package com.itheima;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;

public class Demo01 {
    public static void main(String[] args) throws Exception {
//        1.
        Class.forName("com.mysql.jdbc.Driver");

        //获取连接
        Connection con = DriverManager.getConnection("jdbc:mysql://192.168.23.129:3306/db2", "root", "chenbo123");
        Statement stat = con.createStatement();
        String sql = "SELECT * FROM user";
        ResultSet rs = stat.executeQuery(sql);
        while (rs.next()) {
            System.out.println(rs.getInt("id") + "\t" + rs.getString("name"));
        }
        stat.close();
        con.close();

    }
}
